//
//  GetProductDetailViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/19.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "DiscoverSupplyAgencyViewController.h"


#import "HttpRequest.h"
#import "JSONKit.h"
#import "ProductView.h"
#import "HAODEsingleton.h"
#import "UIButton+WebCache.h"
//#import "productdetailsView.h"
#import "RDVTabBarController.h"
#import "ShopcatListViewController.h"
#import "TheLoginViewController.h"
#import "VPImageCropperViewController.h"
#import <AssetsLibrary/AssetsLibrary.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "UpYun.h"
#import "productdetailsView.h"

#define ORIGINAL_MAX_WIDTH 420.0f
@interface DiscoverSupplyAgencyViewController ()<UIScrollViewDelegate,UIWebViewDelegate, UITextViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIAlertViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIActionSheetDelegate>
@property (nonatomic, strong) UIImageView *portraitImageView;
@property (nonatomic,strong) UIImagePickerController *ipc;
@property (strong, nonatomic) UIImage *sendImage;
@property(nonatomic,retain)NSMutableArray* xuanxiang;
@property (retain, nonatomic) NSDictionary* dictionary;

@property (weak, nonatomic) UIPageControl * pageControl;
@property (nonatomic,retain)UIImageView* image1;


@end

@implementation DiscoverSupplyAgencyViewController
{
    BOOL saveAccount;
    int requestState;
    int goodsPrice;
    UIImage *image;
    HAODEsingleton* commdity;
    UIWebView *webview;
    UIScrollView *myscrollView;
    UIScrollView *scrollView;
    UILabel *textlabel2;
    ProductView*clothView;
    UITableView *table_list;
    UIButton*idname1;
    NSMutableArray*images;
    NSMutableArray*specList;
    NSMutableArray*arr;
    UIView*backview1;
    UIButton*bbuyBtn;
    UIButton*orderBtn1;
    UIButton* backButton1;
    UIButton*buttonimage;
    UIView*view11;
    UIView *guigeview;
    UIView*diview;
    NSDictionary*dataDicts;
    UIButton*tureBtn;
    UIImageView *imageview;
    UILabel* shu;
    NSString*specId;
    UIImageView*chaimageview;
    NSMutableArray*arrays;
    UIButton*buyBtn11;
}




-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=NO;
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    commdity=[HAODEsingleton shared];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    
    
    arr=[[NSMutableArray alloc]init];
    
    images=[[NSMutableArray alloc]init];
    arrays=[[NSMutableArray alloc]init];
    [self add];
    
    
    
}
-(void )add{
    
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    
    [param setValue:commdity.itemId forKey:@"itemId"];
    
    NSLog(@"====%@",param);
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"Discover/Supply/DetailProduct" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"====%@",severDataDict.dataDict);
            
            
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
                dataDicts=severDataDict.dataDict;
                specList=[severDataDict.dataDict objectForKey:@"specList"];
                arrr=[severDataDict.dataDict objectForKey:@"tagList"];
                myscrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight)];
                
                myscrollView.delegate = self;
                myscrollView.userInteractionEnabled = YES;
                myscrollView.scrollEnabled = YES;
                myscrollView.showsVerticalScrollIndicator = FALSE;
                myscrollView.showsHorizontalScrollIndicator = FALSE;
                [self.view addSubview:myscrollView];
                
                
                if (![severDataDict.dataDict isEqual:[NSNull null]]) {
                    
                    productdetailsView *view1 = [[productdetailsView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 450)];
                    
                    view1.itemName.text=[NSString stringWithFormat:@"%@",[severDataDict.dataDict valueForKey:@"itemName"]];
                    view1.itemCode.text=[NSString stringWithFormat:@"No %@",[severDataDict.dataDict valueForKey:@"itemCode"]];
                    view1.saleQty.text=[NSString stringWithFormat:@"销量 %@",[severDataDict.dataDict valueForKey:@"saleQty"]];NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"销量 %@",  [dataDicts valueForKey:@"saleQty"]]];
                    
                    [AttributedStr addAttribute:NSFontAttributeName
                     
                                          value:[UIFont systemFontOfSize:15.0]
                     
                                          range:NSMakeRange(0, 2)];
                    
                    [AttributedStr addAttribute:NSForegroundColorAttributeName
                     
                                          value:zhonghuiColor
                     
                                          range:NSMakeRange(0, 2)];
                    
                    
                    view1.saleQty.attributedText = AttributedStr;
                    
                    
                    if (![severDataDict.dataDict isEqual:[NSNull null]]) {
                        NSMutableArray *array = [NSMutableArray arrayWithCapacity:[[severDataDict.dataDict valueForKey:@"imageList"] count]];
                        
                        for (NSDictionary *dic in [severDataDict.dataDict valueForKey:@"imageList"]) {
                            [array addObject:[dic objectForKey:@"imageUrlFull"]];
                            
                        }
                        view1.arrayImage = array;
                        
                    }else {
                        view1.arrayImage = @[@"http://miandan.b0.upaiyun.com/Product/9aafbbd4-febc-46dc-9197-4f92e87737f1.png"];
                        
                    }
                    
                    
                    [myscrollView addSubview:view1];
                    
                    NSInteger number ;
                    number=[[severDataDict.dataDict objectForKey:@"specList"]count];
                    
                    if (number>0) {
                        
                        for (int i = 0; i < number; i++) {
                            
                            guigeview = [[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+45*i, ScreenWidth, 45)];
                            
                            guigeview.backgroundColor=[UIColor whiteColor];
                            UILabel*specName=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 200, 45)];
                            specName.text=[NSString stringWithFormat:@"%@ 数量%@",[[[severDataDict.dataDict objectForKey:@"specList"]objectAtIndex:i]objectForKey:@"specName"],  [[[severDataDict.dataDict objectForKey:@"specList"]objectAtIndex:i]objectForKey:@"specInv"]];
                            specName.textColor=zhonghuiColor;
                            specName.font=[UIFont systemFontOfSize:15];
                            [guigeview addSubview:specName];
                            UIImageView *_xianview = [[UIImageView alloc]initWithFrame:CGRectMake(15,45-0.35, ScreenWidth-30, 0.5)];
                            _xianview.image=[UIImage imageNamed:@"hengxian"];
                            [guigeview addSubview:_xianview];
                            
                            NSString*GoldPrice=[NSString stringWithFormat:@"%@",  [[[severDataDict.dataDict objectForKey:@"specList"]objectAtIndex:i]objectForKey:@"specPrice"]];
                            NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                            [numberFormatter setPositiveFormat:@"###,##0.00;"];
                            NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
                            UILabel*specPrice=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-120, 0, 100, 45)];
                            specPrice.text=[NSString stringWithFormat:@"¥%@",formattedNumberString];
                            specPrice.textAlignment=NSTextAlignmentRight;
                            specPrice.textColor=hongsecolor;
                            [guigeview addSubview:specPrice];
                            [myscrollView addSubview:guigeview];
                        }
                        
                        
                        if (arrr.count>0) {
                            
                            for (int i = 0,j = 0; i < arrr.count; i++) {
                                if (i % 4 == 0) {
                                    j++;
                                }
                                
                                clothView = [[ProductView alloc]initWithFrame:CGRectMake(12.5+(ScreenWidth/4-5)*(i%4), guigeview.bottom+20-50+(50*j), ScreenWidth/4-15, 20)];
                                
                                clothView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
                                clothView.buttonView.titleLabel.font=[UIFont systemFontOfSize:thirteenfotORtwelvefot];
                                [clothView.buttonView setTitle: [[arrr objectAtIndex:i] objectForKey:@"content"] forState:UIControlStateNormal];
                                clothView.buttonView.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:234/255.0 alpha:1];
                                [clothView.buttonView setTitleColor:huangtitleColor forState:0];
                                [clothView.buttonView.layer setCornerRadius:13.0];
                                [clothView.buttonView.layer setBorderWidth:0.43];
                                [clothView.buttonView.layer setMasksToBounds:YES];
                                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
                                [clothView.buttonView.layer setBorderColor:colorref2];//边框颜色
                                //                [clothView.buttonView addTarget:self action:@selector(ItemCodebut:) forControlEvents:UIControlEventTouchUpInside];
                                [myscrollView addSubview:clothView];
                                
                                
                                
                            }
                            
                            
                        }else {
                            
                            NSMutableArray *array1 = [[NSMutableArray alloc] initWithObjects:
                                                      @"无评论",nil];
                            for (int i = 0,j = 0; i < array1.count; i++) {
                                if (i % 4 == 0) {
                                    j++;
                                }
                                
                                clothView = [[ProductView alloc]initWithFrame:CGRectMake(12.5+(ScreenWidth/4-5)*(i%4), guigeview.bottom+20-50+(50*j), ScreenWidth/4-15, 20)];
                                
                                clothView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
                                clothView.buttonView.titleLabel.font=[UIFont systemFontOfSize:thirteenfotORtwelvefot];
                                [clothView.buttonView setTitle: [array1 objectAtIndex:i]  forState:UIControlStateNormal];
                                clothView.buttonView.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:234/255.0 alpha:1];
                                [clothView.buttonView setTitleColor:huangtitleColor forState:0];
                                [clothView.buttonView.layer setCornerRadius:13.0];
                                [clothView.buttonView.layer setBorderWidth:0.43];
                                [clothView.buttonView.layer setMasksToBounds:YES];
                                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
                                [clothView.buttonView.layer setBorderColor:colorref2];//边框
                                [myscrollView addSubview:clothView];}
                        }
                        
                    }else{
                        
                        UILabel*specPrice=[[UILabel alloc]initWithFrame:CGRectMake(15, view1.bottom+5, 200, 45)];
                        specPrice.text=[NSString stringWithFormat:@"¥ %@",[severDataDict.dataDict objectForKey:@"salePrice"]];
                        specPrice.textColor=hongsecolor;
                        
                        [myscrollView addSubview:specPrice];
                        if (arrr.count>0) {
                            
                            for (int i = 0,j = 0; i < arrr.count; i++) {
                                if (i % 4 == 0) {
                                    j++;
                                }
                                
                                clothView = [[ProductView alloc]initWithFrame:CGRectMake(12.5+(ScreenWidth/4-5)*(i%4), specPrice.bottom+20-50+(50*j), ScreenWidth/4-15, 20)];
                                
                                clothView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
                                clothView.buttonView.titleLabel.font=[UIFont systemFontOfSize:thirteenfotORtwelvefot];
                                [clothView.buttonView setTitle: [[arrr objectAtIndex:i] objectForKey:@"content"] forState:UIControlStateNormal];
                                clothView.buttonView.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:234/255.0 alpha:1];
                                [clothView.buttonView setTitleColor:huangtitleColor forState:0];
                                [clothView.buttonView.layer setCornerRadius:13.0];
                                [clothView.buttonView.layer setBorderWidth:0.43];
                                [clothView.buttonView.layer setMasksToBounds:YES];
                                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
                                [clothView.buttonView.layer setBorderColor:colorref2];//边框颜色
                                //                [clothView.buttonView addTarget:self action:@selector(ItemCodebut:) forControlEvents:UIControlEventTouchUpInside];
                                [myscrollView addSubview:clothView];
                                
                                
                                
                            }
                            
                            
                        }else {
                            NSMutableArray *array1 = [[NSMutableArray alloc] initWithObjects:
                                                      @"无评论",nil];
                            for (int i = 0,j = 0; i < array1.count; i++) {
                                if (i % 4 == 0) {
                                    j++;
                                }
                                
                                clothView = [[ProductView alloc]initWithFrame:CGRectMake(12.5+(ScreenWidth/4-5)*(i%4), specPrice.bottom+20-50+(50*j), ScreenWidth/4-15, 20)];
                                
                                clothView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
                                clothView.buttonView.titleLabel.font=[UIFont systemFontOfSize:thirteenfotORtwelvefot];
                                [clothView.buttonView setTitle: [array1 objectAtIndex:i]  forState:UIControlStateNormal];
                                clothView.buttonView.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:234/255.0 alpha:1];
                                [clothView.buttonView setTitleColor:huangtitleColor forState:0];
                                [clothView.buttonView.layer setCornerRadius:13.0];
                                [clothView.buttonView.layer setBorderWidth:0.43];
                                [clothView.buttonView.layer setMasksToBounds:YES];
                                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
                                [clothView.buttonView.layer setBorderColor:colorref2];//边框
                                [myscrollView addSubview:clothView];}
                            
                            
                        }
                        
                        
                    }
                    
                    
                    
                    UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(15, clothView.bottom+25, ScreenWidth-30, 0.40)];
                    line.backgroundColor=LineColor;
                    [myscrollView addSubview:line];
                    
                    
                    UILabel*xiangqing=[[UILabel alloc]initWithFrame:CGRectMake(15, line.bottom+20, 100, 16)];
                    xiangqing.text=@"详情描述";
                    xiangqing.textColor=[UIColor blackColor];
                    xiangqing.font=[UIFont systemFontOfSize:15];
                    [myscrollView addSubview:xiangqing];
                    
                    
                    
                    NSString *s12 = [NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"details"]];
                    UIFont *font12 = [UIFont systemFontOfSize:15];
                    CGSize size12 = CGSizeMake(ScreenWidth-30, 2000);
                    CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
                    
                    
                    
                    UILabel*details2=[[UILabel alloc]initWithFrame:CGRectMake(15, xiangqing.bottom+25, ScreenWidth-30, labelsize12.height)];
                    details2.text=[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"details"]];
                    details2.textColor=shenhuicolor;
                    details2.numberOfLines=0;
                    details2.font=[UIFont systemFontOfSize:15];
                    [myscrollView addSubview:details2];
                    
                    
                    [myscrollView setContentSize:CGSizeMake(ScreenWidth, details2.bottom+64)];                    
                    
                    
                    
                    
                    
                    
                    
                    
                    idname1 = [[UIButton alloc] initWithFrame:CGRectMake(80*ScreenWidth/750, 5, 20, 20)];
                    idname1.backgroundColor=[UIColor colorWithRed:229.00/255.00 green:19/255.00 blue:19/255.00 alpha:1.0];
                    [idname1 setTitle:[NSString stringWithFormat: @"%d",0]forState:UIControlStateNormal];
                    idname1 .titleLabel.font=[UIFont systemFontOfSize:14];
                    idname1.layer.masksToBounds = YES;
                    idname1.layer.cornerRadius = 10;
                    idname1.layer.borderColor = [UIColor whiteColor].CGColor;
                    idname1.layer.borderWidth = 0;
                    //idname.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
                    idname1.titleLabel.textAlignment = NSTextAlignmentCenter;
                    [bbuyBtn addSubview:idname1];
                    
                    
                    
                    UILabel*line1=[[UILabel alloc]initWithFrame:CGRectMake(0, ScreenHeight-45, ScreenWidth, 0.40)];
                    line1.backgroundColor=LineColor;
                    [self.view addSubview:line1];
                    
                    
                    
                    if ([[severDataDict.dataDict objectForKey:@"isAgency"]isEqualToString:@"Y"]) {
                        buyBtn11=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-45, ScreenWidth, 45)];
                        [buyBtn11 setTitle:@"加入代销" forState:UIControlStateNormal];
                        buyBtn11.backgroundColor=qianhuicolor;
                        [buyBtn11 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        [self.view addSubview:buyBtn11];

                    }else{
                   buyBtn11=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-45, ScreenWidth, 45)];
                    [buyBtn11 setTitle:@"加入代销" forState:UIControlStateNormal];
                    buyBtn11.backgroundColor=luseColor;
                    [buyBtn11 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                    
                    [buyBtn11 addTarget:self action:@selector(addcat:) forControlEvents:UIControlEventTouchUpInside];
                    [self.view addSubview:buyBtn11];
                    }
                    
                }
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
}

-(void)closeKeyBoad
{
    [tureBtn removeFromSuperview];
    [diview removeFromSuperview];
    [scrollView removeFromSuperview];
    [chaimageview removeFromSuperview];
}


-(void)addcat:(UIButton*)sender
{
   
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    
    [param setValue:commdity.itemId forKey:@"itemId"];
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"/Discover/Supply/Agency" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                 [buyBtn11 removeFromSuperview];
                [Global showTextHudSub:requestResultStr view:self.view];
                buyBtn11=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-45, ScreenWidth, 45)];
                [buyBtn11 setTitle:@"加入代销" forState:UIControlStateNormal];
                buyBtn11.backgroundColor=qianhuicolor;
                [buyBtn11 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                [self.view addSubview:buyBtn11];

               
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
    
}
- (UIViewController *)appRootViewController
{
    UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *topVC = appRootVC;
    while (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }
    return topVC;
}

- (void)tapAction {
    UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    scroll.backgroundColor = [UIColor blackColor];
    [[self appRootViewController].view addSubview:scroll];
    
    UIImageView *imagev = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,ScreenWidth*image.size.height/image.size.width)];
    imagev.image = image;
    if (imagev.frame.size.height < ScreenHeight) {
        imagev.center = scroll.center;
    }
    
    [scroll addSubview:imagev];
    scroll.contentSize = CGSizeMake(ScreenWidth, imagev.frame.size.height);
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction2)];
    [scroll addGestureRecognizer:tap];
    scroll.tag = 100;
}

- (void)tapAction2 {
    UIScrollView *scroll = (UIScrollView *)[[self appRootViewController].view viewWithTag:100];
    [scroll removeFromSuperview];
}




@end
